#!/usr/bin/env bash

APOLLO_ROOT_DIR="/apollo"
APOLLO_BIN_PREFIX="${APOLLO_ROOT_DIR}/bazel-bin"

neolix_map=$1
dir_name=$2

if [ -z ${dir_name} ]; then
    echo "usage: $0 [neolix_map] [map_dir]"
    exit 0
fi

/apollo/neolix_tools/hd_mapping/6.map_transform/cyberrt_to_apollo ${neolix_map}

mkdir -p ${dir_name}
cp "${neolix_map}_apollo.bin" ${dir_name}/base_map.bin
echo "--map_dir=${dir_name}" >> ${APOLLO_ROOT_DIR}/modules/common/data/global_flagfile.txt
${APOLLO_BIN_PREFIX}/modules/routing/topo_creator/topo_creator --flagfile=/apollo/modules/routing/conf/routing.conf
${APOLLO_BIN_PREFIX}/modules/map/tools/sim_map_generator --map_dir=${dir_name} --output_dir=${dir_name}
